﻿using SnShared;
using SnShared.Models;
using System.Data.Entity;

namespace CdmDeviceHealthMvc.Models
{
    public class CdmDataCtx : DbContext
    {
        public CdmDataCtx() : base()
        {

        }

        public CdmDataCtx( string connectionString ) : base( connectionString )
        {

        }

        public static CdmDataCtx CreateDbContext()
        {
            string connectionString = Config.GetConnectionString();
            CdmDataCtx ret = new CdmDataCtx( connectionString );

            // connection string timeout is ignored...
            // see http://stackoverflow.com/questions/6232633/entity-framework-timeouts
            ret.Database.CommandTimeout = 6666;
            return ret;
        }

        public DbSet<Computer> Computers { get; set; }
        public DbSet<SoftwarePackage> SoftwarePackages { get; set; }        
             
    }
}
